package com.example.demo.domain;

/*public class User {

    private Long id;
    private String name;
    private Integer age;
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }


}*/
import java.util.Scanner;

public class User {
    private String name;
    // private int identity;//买家0,卖家1
    public User() {
    }

    public User(String name) {
        this.name = name;
    }

    public void browse() {
        System.out.println(this.name + "浏览了在售电驴列表");
        BicycleList bicycleList = BicycleList.GetBicycleList();
        bicycleList.display();
    }

    public void post(Group group) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("电驴型号：");
        String type = scanner.nextLine();
        System.out.print("生产厂家：");
        String brand = scanner.nextLine();
        System.out.print("原价：");
        float priceBefore = Float.parseFloat(scanner.nextLine());
        System.out.print("售价：");
        float priceSell = Float.parseFloat(scanner.nextLine());
        System.out.print("新旧程度：");
        String condition = scanner.nextLine();

        Bicycle bicycle = new Bicycle(type, brand, priceBefore, priceSell, condition,this.getName());
        BicycleList bicycleList = BicycleList.GetBicycleList();
        bicycleList.add(bicycle);
        System.out.println("用户" + this.name + "发布了一辆待售电驴：" + bicycle);
        group.NotifyUser(this.name, bicycle.getType());
    }

    public void post(Bicycle bicycle, Group group) {
        BicycleList bicycleList = BicycleList.GetBicycleList();
        bicycleList.add(bicycle);
        System.out.println("用户" + this.name + "发布了一辆待售电驴：" + bicycle);
        group.NotifyUser(this.name, bicycle.getType());
    }

    public void onlooker() {
        System.out.println(this.name + " 快来看看吧！");
    }

    public String getName() {
        return name;
    }

}

